<?php
require_once "../../../../../PCO.php";
require_once "../../../../../global-themis/functions/function_graph_2.php";
require_once "../../../../../global-themis/functions/function_graph.php";
require_once "../../../../../global-themis/functions/functions.php";
$resultat="";
$data=array();
$title=array();
$render_to="";
$compte="";
$width="";
$height="";
$resultat="";
$tab=array();
$coord_name="";
$mouv=array();
$matrice=array();
	if(isset($_POST['selec_compte'])){
		$compte="";
		$compte=$_POST['selec_compte'];
		$width=$_POST['wid'];
		$height=$_POST['hei'];
		$render_to="container";
		$title='';
		$data=getData($compte);
		 // print_r($data);
		$resultat.=buildChart($data, $render_to, $width, $height, $title, 'area');
		echo "	<script src='../../../../global-themis/js/highstock.js' type='text/javascript'></script>
				<script type='text/javascript' src='../../../../global-themis/js/modules/exporting.js'></script>
				<script type='text/javascript' src='../../../../global-themis/js/themes/gray.js'></script>
				<script type='text/javascript'>";
				echo $resultat;
				echo "</script>";
	}
	if(isset($_POST['selec_compte_flux'])){
		$compte=$_POST['selec_compte_flux'];
		$width=$_POST['wid'];
		$height=$_POST['hei'];
		$tab[0]="container";
		$tab[1]="column";
		$tab[2]="";
		$tab[3]="";
		$titre=array('D_AV0', 'D_TRF', 'D_CPT ', 'D_AOV ', 'D_RIO ', 'D_RLO ', 'D_RPO ', 'D_RTO ', 'D_T_FR', 'D_T_ETR', 'C_TRF', 'C_CPT', 'C_AIO', 'C_APO', 'C_RVO', 'C_ROV', 'C_T_FR', 'C_T_ETR');
		$matrice=buildMatriceFluxCompte($compte, $tab[2], $titre);
		$resultat=buildChartTwoColumns($matrice, $coord_name, $tab, $width, $height);
		echo "<script type='text/javascript'>";
		echo $resultat;
	    echo "</script>";
	}	
	if(isset($_POST['selec_compte_mouv'])){
		$compte=$_POST['selec_compte_mouv'];
		$mouv=getMouvementBycompte($compte);
		$count=count($mouv);
		if($count < 6) {
			$count=6 -$count;
		}
		else {
			$count=0;
		}
		if(empty($mouv)){
			$resultat="Aucun mouvement client depuis 90 jours..";
		}
		else {
				$resultat="<script type=\"text/javascript\" src=\"../../../../global-themis/js/jquery.tablescroll.js\"></script>
					
			<script>
				$(document).ready(function(){
					$('#tab_mouv').tableScroll('undo');
				});
			</script>		
			</head>
				<table id='tab_mouv'  class='tablescroll' width='100%'>";
				$resultat.="<thead>";
				$resultat.="<td id='ss'>MON<td>DATE COM<td> CODE OP<td>NUM OP<td>EVE</thead>";
				$resultat.="<tbody>";
				foreach ($mouv as $m){
					$resultat.="<tr title='".$m['LIBELLIB']."'><td>".colorNegative($m['MOUVEMMON'])."<td>".reConvertDate($m['MOUVEMDCO'])."<td>".$m['MOUVEMOPE']."<td>".$m['MOUVEMNUM']."<td>".$m['MOUVEMEVE']."</td></tr>";
				}
				$i=0;
				if($count >0)
				while($i<$count) {
					$resultat.="<tr><td colspan='5'>&nbsp;</td></tr>";
					$i++;
				}
				else {
				}
				$resultat."</tbody></table>";
		}
	echo $resultat;
	}	
		
?>
